/*
 * Copyright (c) 2009 John Pritchard, WTKX Project Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package wtkx;

import jbxml.Reflector;

/**
 * A WTKX object element identifies an alternative application object.
 * The following example calls a method named "hit" on class
 * "pkg.class.Name".
 * 
 * <pre>
 * &lt;object id="foo" code="pkg.class.Name" /&gt;
 * &lt;button id="b" target="foo" onclick="hit" /&gt;
 * </pre>
 * 
 * Alternatively, for any class with a public, "no arg" constructor.
 * 
 * <pre>
 * &lt;any:name xmlns:any="pkg.class" id="foo" /&gt;
 * &lt;button id="b" target="foo" onclick="hit" /&gt;
 * </pre>
 * 
 * The preferred form is debateable.
 * 
 * Note that button "b" and its children will have all their functions
 * bound to the target object.
 * 
 * The object should be a child of the window -- an immediate
 * descendent of the document element.
 * 
 * @author jdp
 */
public class Object
    extends java.lang.Object
    implements jbxml.Component.Child
{
    protected volatile Reflector reflector;

    protected volatile jbxml.Component parent;

    protected volatile String id;

    protected volatile String code;

    protected volatile java.lang.Object value;


    public Object(){
        super();
    }


    public String getId(){
        return this.id;
    }
    public void setId(String id){
        this.id = id;
    }
    public String getCode(){
        return this.code;
    }
    public void setCode(String code){
        this.code = code;
    }
    public java.lang.Object getValue(){
        return this.value;
    }
    public void setValue(java.lang.Object value){
        this.value = value;
    }
    public void startElement(Reflector bean){
        this.reflector = bean;
    }
    public void endElement(){
        if (null == this.value && null != this.code){
            try {
                this.value = Class.forName(this.code);
            }
            catch (Exception exc){
                exc.printStackTrace();
            }
        }
    }
    public void init(Window w, Application a){
    }
    public void destroy(){
    }
    public final Reflector getReflect(){
        return this.reflector;
    }
    public jbxml.Component getParent(){
        return this.parent;
    }
    public final void setParent(jbxml.Component p){
        this.parent = p;
    }
}
